// 球员数据存储
let players = [
    {
        id: 1,
        name: "王大锤",
        number: 10,
        position: "前锋",
        age: 28,
        nationality: "中国",
        description: "王大锤是村姑俱乐部的队长和核心球员，拥有出色的射门和组织能力。他在过去三个赛季中为球队贡献了超过50个进球和30次助攻，是球队进攻的核心。他的领导能力和场上表现使他成为球迷最喜爱的球员之一。",
        image: "https://images.unsplash.com/photo-1570498839593-e565b39455fc?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60",
        stats: {
            pace: 85,
            shooting: 88,
            passing: 90,
            dribbling: 87,
            defending: 45,
            physical: 75
        }
    },
    {
        id: 2,
        name: "李铁脚",
        number: 5,
        position: "中场",
        age: 26,
        nationality: "中国",
        description: "李铁脚是球队中场的核心，拥有出色的传球视野和控球能力。他的长传精准，战术意识强，是球队进攻组织的关键人物。在防守端，他也能提供有力的支持，是一名全能型中场球员。",
        image: "https://images.unsplash.com/photo-1543326727-cf6c39e8f84c?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60",
        stats: {
            pace: 75,
            shooting: 70,
            passing: 92,
            dribbling: 85,
            defending: 78,
            physical: 80
        }
    },
    {
        id: 3,
        name: "张守门",
        number: 1,
        position: "门将",
        age: 30,
        nationality: "中国",
        description: "张守门是球队的第一门将，拥有出色的反应能力和扑救技术。他在关键比赛中多次挽救球队，是防线上最后的保障。他的指挥能力和出球技术也很出色，是一名现代化的门将。",
        image: "https://images.unsplash.com/photo-1622279457486-28f993f78ade?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60",
        stats: {
            pace: 50,
            shooting: 20,
            passing: 65,
            dribbling: 30,
            defending: 25,
            physical: 85
        }
    },
    {
        id: 4,
        name: "刘铁壁",
        number: 4,
        position: "后卫",
        age: 29,
        nationality: "中国",
        description: "刘铁壁是球队防线的中坚力量，身体强壮，抢断精准。他的头球能力出色，在防守定位球时发挥重要作用。同时，他也能在进攻端通过头球为球队贡献进球。",
        image: "https://images.unsplash.com/photo-1574629810360-7efbbe195018?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60",
        stats: {
            pace: 70,
            shooting: 45,
            passing: 65,
            dribbling: 55,
            defending: 90,
            physical: 88
        }
    },
    {
        id: 5,
        name: "赵快腿",
        number: 7,
        position: "前锋",
        age: 24,
        nationality: "中国",
        description: "赵快腿是球队最快的球员，边路突破能力出色。他的速度和灵活性使他成为对方防线的噩梦。虽然他的射门和传球还有提升空间，但他的速度优势已经为球队赢得了许多比赛。",
        image: "https://images.unsplash.com/photo-1564415315949-7a0c4c73aab4?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60",
        stats: {
            pace: 95,
            shooting: 75,
            passing: 68,
            dribbling: 85,
            defending: 40,
            physical: 72
        }
    },
    {
        id: 6,
        name: "孙技术",
        number: 11,
        position: "中场",
        age: 25,
        nationality: "中国",
        description: "孙技术是球队技术最精湛的球员之一，盘带和传球都非常出色。他的创造力和视野使他能够为前锋创造出绝佳的得分机会。他的任意球和角球也是球队的重要武器。",
        image: "https://images.unsplash.com/photo-1560272564-c83b66b1ad12?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60",
        stats: {
            pace: 78,
            shooting: 80,
            passing: 88,
            dribbling: 92,
            defending: 60,
            physical: 65
        }
    }
];

// 俱乐部徽章图片URL
let clubLogo = "https://via.placeholder.com/150";

// 保存数据到本地存储
function saveData() {
    localStorage.setItem('players', JSON.stringify(players));
    localStorage.setItem('clubLogo', clubLogo);
}

// 从本地存储加载数据
function loadData() {
    const storedPlayers = localStorage.getItem('players');
    const storedLogo = localStorage.getItem('clubLogo');
    
    if (storedPlayers) {
        players = JSON.parse(storedPlayers);
    }
    
    if (storedLogo) {
        clubLogo = storedLogo;
        updateLogoDisplay();
    }
}

// 更新所有徽章显示
function updateLogoDisplay() {
    const logoElements = document.querySelectorAll('#club-logo, #footer-club-logo');
    logoElements.forEach(element => {
        element.src = clubLogo;
    });
}

// 初始化数据
function initData() {
    loadData();
    updateLogoDisplay();
}

// 页面加载时初始化数据
document.addEventListener('DOMContentLoaded', initData);